//
//  CoreDataManager.h
//  alotOf
//
//  Created by Mac_Black_Mini on 2025/9/4.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

NS_ASSUME_NONNULL_BEGIN

@interface CoreDataManager : NSObject



///管理对象上下文
@property (nonatomic, strong)  NSManagedObjectContext *managedObjectContext;
///管理对象模型
@property (nonatomic, strong) NSManagedObjectModel *managedObjectModel;
///持久化存储调度器
@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator;

+ (instancetype)sharedInstance;
- (BOOL)saveContextWithError:(NSError **)error;
- (nullable NSArray<NSManagedObject *> *)queryDataWithEntityName:(NSString *)entityName
                                                       predicate:(nullable NSPredicate *)predicate
                                               sortDescriptors:(nullable NSArray<NSSortDescriptor *> *)sortDescriptors
                                                         limit:(nullable NSNumber *)limit
                                                        offset:(nullable NSNumber *)offset
                                                           error:(NSError **)error;
- (BOOL)modifyDataWithEntityName:(NSString *)entityName
                       predicate:(nullable NSPredicate *)predicate
                     modifyBlock:(void(^)(NSManagedObject *object))modifyBlock
                           error:(NSError **)error;
- (BOOL)deleteDataWithEntityName:(NSString *)entityName
                       predicate:(nullable NSPredicate *)predicate
                           error:(NSError **)error;
- (void)saveContext;
@end




NS_ASSUME_NONNULL_END
